import { useState } from 'react';

export default function AddTodo({ onAddTodo }) {
  const [title, setTitle] = useState('');
  return (
    <>
      <label>
        <input
          value={title}
          onChange={(e) => setTitle(e.target.value)}
          type="text"
          placeholder="Add todo"
        />
        <button
          onClick={() => {
            setTitle('');
            onAddTodo(title);
          }}
        >
          Add
        </button>
      </label>
    </>
  );
}
